package com.hksj.vsm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hksj.base.vo.DeviceOverviewVO;
import com.hksj.common.core.model.Rest;
import com.hksj.vsm.query.SpecialityVideoDeviceQuery;
import com.hksj.vsm.service.VideoDeviceInfoService;
import com.hksj.vsm.vo.PlayVideoVO;
import com.hksj.vsm.vo.SpecialityVideoDeviceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 视频设备数据查询接口
 */

@Api(tags = "视频监控-视频设备查询")
@RestController
@RequestMapping("/api/videoDevice/query")
public class VideoDeviceInfoController {
    @Autowired
    private VideoDeviceInfoService videoDeviceInfoService;

    @ApiOperation(value = "大屏-分页查询设备列表",response = SpecialityVideoDeviceVO.class)
    @PostMapping("/pageDevice")
    public Rest<Page<SpecialityVideoDeviceVO>> pageDevice(@RequestBody @Validated SpecialityVideoDeviceQuery query){
        Page<SpecialityVideoDeviceVO> page = videoDeviceInfoService.pageDevice(query);
        return Rest.ok(page);
    }

    @ApiOperation("大屏-设备概览")
    @PostMapping("/getDeviceOverview")
    public Rest<DeviceOverviewVO> getDeviceOverview(@RequestBody @Validated SpecialityVideoDeviceQuery query){
        DeviceOverviewVO res = videoDeviceInfoService.getDeviceOverview(query);
        return Rest.ok(res);
    }


    @ApiOperation("大屏-查询单个设备的监控视频")
    @PostMapping("/getPlayVideoInfo/{deviceId}")
    public Rest<PlayVideoVO> getPlayVideoInfo(@PathVariable String deviceId){
        PlayVideoVO playVideoVO = videoDeviceInfoService.getPlayVideoInfo(deviceId);
        return Rest.ok(playVideoVO);
    }

    @ApiOperation(value = "大屏-分页查询房间多个监控视频",response = SpecialityVideoDeviceVO.class)
    @PostMapping("/pagePlayVideoInfo")
    public Rest<Page<PlayVideoVO>> pagePlayVideoInfo(@RequestBody @Validated SpecialityVideoDeviceQuery query){
        Page<PlayVideoVO> page = videoDeviceInfoService.pagePlayVideoInfo(query);
        return Rest.ok(page);
    }
}
